<!-- 继承blog/base.html ⽂件 -->
{% extends "blog/base.html" %}
<!-- 加载自定义标签 --> 
{% load blog_tags %}
<!-- 使⽤此处标题块内容替换blog/base.html⽂件中标题块 -->
{% block title %}My Blog{% endblock %}
<!-- 使⽤此处内容块代码替换blog/base.html⽂件中内容块-->
{% block content %}
<h1>My Blog</h1>
{% if tag %}
<h2>文章标签 "{{ tag.name }}"</h2>
{% endif %}
{% for post in posts %}
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2> 
<!-- 显示此文章所有标签 --> 
<p class="tags"> 
  Tags: 
<!-- <h2>{{ post.title }}</h2>
<p class="tags"> Tags: -->
  
  {% for tag in post.tags.all %}
  <!-- 每个标签都是⼀个链接，点击即可过滤含有此标签的⽂章进⾏显示 -->
  <a href="{% url 'blog:post_list_by_tag' tag.slug %}">
    {{ tag.name }} </a>
  <!-- 若不是最后⼀个标签显示逗号 -->
  {% if not forloop.last %}, {% endif %}
  {% endfor %}
<p class="date">Published {{ post.publish }} by {{ post.author }}
</p>
<p>{{post.body|markdown|truncatewords_html:30}}</p>
{% endfor %}
<!-- 引⼊分⻚模板 -->
{% include "pagination.html" with page=posts %}
{% endblock %}